﻿// Bing Maps ASP.NEt Control is a community project available under the Microsoft Public License (Ms-PL)
// Code is provided as is and with no warrenty – Use at your own risk
// View the project and the latest code at http://BingMapsASP.codeplex.com

using System;

namespace Microsoft.Live.ServerControls.VE
{
    /// <summary>
    /// Specifies the color and transparency to use when drawing VEPolyline Class objects on the map
    /// </summary>
    [Serializable]
    public sealed class Color
    {
        private int r;
        private int g;
        private int b;
        private double a;

        /// <summary>
        /// Initializes a new instance of the VEColor object
        /// </summary>
        public Color()
        {
            A = 1.0;
        }

        /// <summary>
        /// Initializes a new instance of the VEColor object
        /// </summary>
        /// <param name="r">Specifies the red component value. Valid values range from 0 through 255</param>
        /// <param name="g">Specifies the green component value. Valid values range from 0 through 255</param>
        /// <param name="b">Specifies the blue component value. Valid values range from 0 through 255</param>
        /// <param name="a">Specifies the alpha (transparency) component value. Valid values range from 0.0 through 1.0</param>
        public Color(int r, int g, int b, double a)
        {
            R = r;
            G = g;
            B = b;
            A = a;
        }

        /// <summary>
        /// Specifies the red component value. Valid values range from 0 through 255
        /// </summary>
        public int R
        {
            get { return r; }
            set { r = (value >= 0 && value <= 255) ? value : 0; }
        }

        /// <summary>
        /// Specifies the green component value. Valid values range from 0 through 255
        /// </summary>
        public int G
        {
            get { return g; }
            set { g = (value >= 0 && value <= 255) ? value : 0; }
        }

        /// <summary>
        /// Specifies the blue component value. Valid values range from 0 through 255
        /// </summary>
        public int B
        {
            get { return b; }
            set { b = (value >= 0 && value <= 255) ? value : 0; }
        }

        /// <summary>
        /// Specifies the alpha (transparency) component value. Valid values range from 0.0 through 1.0.
        /// </summary>
        public double A
        {
            get { return a; }
            set { a = (value >= 0 && value <= 1) ? value : 1; }
        }
    }
}
